# -*- coding: utf-8 -*-

# Copyright(c) 2012 mielove.com

import tornado.wsgi
import sae
import os
from tornado.options import options

from libs.utils import parse_config_file
parse_config_file('mielove.conf')
tornado.options.parse_command_line()

import sys 
reload(sys) 
sys.setdefaultencoding('utf8') 


from urls import handlers

import libs.modules as modules
'''
tornado settings
'''
settings = dict(
	root_path = os.path.dirname(__file__),
	debug = options.debug,
	xsrf_cookies = options.xsrf_cookies,
	cookie_secret = options.cookie_secret,
	login_url = options.login_url,
	template_path = os.path.join(os.path.dirname(__file__), "templates"),
	static_path = os.path.join(os.path.dirname(__file__), "static"),
	ui_modules = modules
)

app = tornado.wsgi.WSGIApplication(handlers,**settings)
application = sae.create_wsgi_app(app)
